package com.ids.actions;

import java.util.Map;
import com.ids.service.AdminPasswordService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ChangeAdminPassword extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private String empCode;
	private String oldPassword;
	private String newPassword;
	private String confirmPassword;

	public String execute() throws Exception {
		boolean forward = false;
		if (confirmPassword.equals(newPassword)) {
		Map<String, Object> session = ActionContext.getContext().getSession();
		String empCode = (String) session.get("empCode");
		System.out.println(empCode);
		AdminPasswordService adminPasswordService = new AdminPasswordService();
		String result = adminPasswordService.updateAdminPassword(empCode,
			oldPassword, newPassword);
			if (result.equals("success")){
				forward = true;
			}
		}
		if (!forward) {
			return ERROR;
		}
		return SUCCESS;
	}

	public String getEmpCode() {
		return empCode;
	}

	public void setEmpCode(String empCode) {
		this.empCode = empCode;
	}

	public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

}
